package com.gomes.demo;

import com.gomes.entity.User;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>this class</P>
 *
 * @author gomes
 * @date 2023/9/18 10:33
 */
public class CollectionDemo {


    public static void main(String[] args) {
        List<User> users = userList();
        users.forEach(System.out::println);





    }


    public static List<User> removeDuplicate(List<User> userList) {
        return userList.stream().collect(Collectors.collectingAndThen(
                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User::getId))), ArrayList::new));
    }

    private static List<User> userList() {
        User tom = User.builder().big(new BigDecimal("10")).name("tom").build();
        User sam = User.builder().big(new BigDecimal("20")).name("sam").build();
        User sam2 = User.builder().big(new BigDecimal("55")).name("sam").build();
        User lisa = User.builder().big(new BigDecimal("30")).name("lisa").build();
        User tom2 = User.builder().big(new BigDecimal("40")).name("tom").build();
        return Arrays.asList(tom, sam, sam2, lisa, tom2);
    }


}
